import sys

data = sys.stdin.readlines()

def binary_search(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        midval = a[mid]
        if midval < x:
            lo = mid+1
        elif midval > x: 
            hi = mid
        else:
            return mid
    return -1

def read_data(nums):
    ncount, k = data[0].split()
    ncount, k = int(ncount), int(k)
    count = 0;
    for strin in data[1].split():
        nums.append(int(strin))
        count = count + 1
        if(count == ncount): break;
    return (ncount, k)

nums = []
ncount, k = read_data(nums)
nums.sort()

pair_count = 0
for i in nums:
    if binary_search(nums, i + k) != -1:
        pair_count = pair_count + 1

print(pair_count)
